<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>登录</title>
    <style>
        * {
            padding: 0;
            margin: 0;
        }

        body {
            background: url(./bg.jpeg);
        }

        .outer-box {
            width: 300px;
            margin: 100px auto;
            background-color: white;
            border-radius: 10px;
        }


        .outer-box .title {
            width: 100%;
            line-height: 50px;
            font-size: 18px;
            color: white;
            text-align: center;
            background-color: rgb(158, 220, 249);
            border-radius: 10px 10px 0 0;
        }

        .outer-box .inner-box {
            padding: 30px;
        }

        .outer-box .inner-box .block {
            width: 100%;
            margin: 20px 0;
            overflow: hidden;
        }

        .outer-box .inner-box .block input {
            width: 100%;
            height: 30px;
            border-radius: 5px;
            border: 2px solid #ccc;
            box-sizing: border-box;
            padding-left: 10px;
        }

        .outer-box .inner-box .block span {
            font-size: 14px;
            color: #ccc;
            cursor: pointer;
            margin: 0 10px;
        }

        .outer-box .inner-box .block .s1 {
            float: left;
        }

        .outer-box .inner-box .block .s2 {
            float: right;
        }

        .outer-box .inner-box .block:last-child input {
            width: 60px;
            background-color: rgb(126, 239, 126);
            color: white;
            line-height: 100%;
            padding: 10px;
            margin-left: 85px;
            cursor: pointer;
            border: none;
        }
    </style>
</head>

<body>
    <div class="outer-box">
        <div class="title">欢迎登录后台管理系统</div>
        <div class="inner-box">
            <div class="block">
                <input type="text" placeholder="输入用户名">
            </div>
            <div class="block">
                <input type="password" placeholder="输入密码">
            </div>
            <div class="block">
                <span class="s1">去注册</span>
                <span class="s2">忘记密码</span>
            </div>
            <div class="block">
                <input type="button" value="登录">
            </div>
        </div>
    </div>
</body>

</html>
<script src="./axios.min.js"></script>
<script>

    var inputs = document.querySelectorAll('input');
    inputs[2].onclick = () => {
        axios.post('/user/login', { phone: inputs[0].value, pass: inputs[1].value }).then((res) => {
            console.log(res.data);
            if(res.data.code == 200){
                window.location.href = 'http://localhost:2022/index.html';
            }else{
                alert(res.data.msg);
            }
        })
    }

    document.querySelector('.s1').onclick = ()=>{
        window.location.href = 'http://localhost:2022/注册.html';
    }

</script>